//
//  MeCell.m
//  Molian
//
//  Created by 胡津 on 15/4/9.
//  Copyright (c) 2015年 xiaocan. All rights reserved.
//

#import "MeCell.h"

@implementation MeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        //图标
        self.IcoView = [[UIImageView alloc]initWithFrame:CGRectMake(10, (50-30)/2, 30, 30)];
        [self.IcoView setContentMode:UIViewContentModeScaleAspectFill];
        self.IcoView.clipsToBounds = YES;
        [self.contentView addSubview:self.IcoView];
        
        //标题
        self.TitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, DeviceWidth-100, 50)];
        self.TitleLabel.textColor = RGBA(51, 51, 51, 1);
        self.TitleLabel.font = [UIFont fontWithName:FontName size:16];
        [self.contentView addSubview:self.TitleLabel];
        
        //角标
        self.redDotView = [[UIView alloc]initWithFrame:CGRectMake(DeviceWidth-50, (50-7.5)/2, 7.5, 7.5)];
        self.redDotView.layer.masksToBounds = YES;//开启圆角
        [self.redDotView.layer setCornerRadius:7.5/2];
        self.redDotView.backgroundColor = UIColorFromRGB(0xFE6A66);
        self.redDotView.hidden = YES;
        [self.contentView addSubview:self.redDotView];
        CATransition *trans=[[CATransition alloc]init];
        [trans setType:kCATransitionReveal];
        [trans setSubtype:kCATransitionFromLeft];
        [trans setDuration:0.5];
        [self.TitleLabel.layer addAnimation:trans forKey:nil];

    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    if (!self.moneyLabel) {
        if (self.moneyStr) {
            self.moneyLabel = [[UILabel alloc]init];
            self.moneyLabel.frame = CGRectMake(DeviceWidth-130, (50-12)/2, 100, 12);
            self.moneyLabel.textColor = [UIColor grayColor];
            self.moneyLabel.textAlignment = NSTextAlignmentRight;
            self.moneyLabel.font = [UIFont fontWithName:FontName size:11];
            self.moneyLabel.text = self.moneyStr;
            [self.contentView addSubview:self.moneyLabel];
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
